import request from '@/utils/request'

// 查询岗位列表
export function listPost(query) {
  return request({
    url: '/system/post/list',
    method: 'get',
    params: query
  })
}

// 查询岗位详细
export function getPost(postId) {
  return request({
    url: '/system/post/' + postId,
    method: 'get'
  })
}

// 新增岗位
export function addPost(data) {
  return request({
    url: '/system/post',
    method: 'post',
    data: data
  })
}

// 修改岗位
export function updatePost(data) {
  return request({
    url: '/system/post',
    method: 'put',
    data: data
  })
}

// 删除岗位
export function delPost(postId) {
  return request({
    url: '/system/post/' + postId,
    method: 'delete'
  })
}

// 岗位状态修改
export function changePostStatus(postId, status) {
  const data = {
    postId,
    status
  }
  return request({
    url: '/system/post/changeStatus',
    method: 'put',
    data: data
  })
}

//  查询角色下岗位
export function getRolePosts(data) {
  return request({
    url: '/system/post/getRolePosts',
    method: 'get',
    params: data
  })
}

//  根据岗位ID和应用ID查询角色权限
export function selectByAppIdPostId(data) {
  return request({
    url: '/system/post/selectByAppIdPostId',
    method: 'get',
    params: data
  })
}

//  批量授权岗位用户
export function selectAuthUserAll(data) {
  return request({
    url: '/system/post/authUser/selectAll',
    method: 'post',
    data: data
  })
}

//  查询未授权用户
export function selectUnSelectUser(data) {
  return request({
    url: `/system/post/authUser/selectUnSelectUser/`,
    method: 'get',
    params: data
  })
}

// 批量取消授权用户
export function cancelAll(data) {
  return request({
    url: `/system/post/authUser/cancelAll/`,
    method: 'post',
    data: data
  })
}

export function cancelOne(data) {
  return request({
    url: `/system/post/authUser/cancelOne/`,
    method: 'put',
    data: data
  })
}

// 根据部门IDS获取对应的岗位信息
export function getPostsByDeptIds(deptIds) {
  return request({
    url: `/system/sysDeptPost/getByDeptIds`,
    method: 'post',
    data: deptIds
  })
}
